<%@page import="conectar.Conectar"%>
<%@page import="java.sql.ResultSet"%>
<%@page session="true" %>
<%@page import="org.w3c.dom.Document"%>
<%
    String usuario = "";
    HttpSession sesionOk = request.getSession();
    if (sesionOk.getAttribute("usuario") == null) {
%>
<jsp:forward page="login.jsp">
    <jsp:param name="error" value="Es
               obligatorio identificarse"/>
</jsp:forward>
<%    } else {
        usuario = (String) sesionOk.getAttribute("usuario");
    }
%>
<!DOCTYPE html>
<html>
    <head>
        <title>Tarjeta Electoral</title>
        <link rel="stylesheet" type="text/css" href="css/default.css" />
        <link rel="stylesheet" type="text/css" href="css/style.css" />
    </head>
    <body>
        <header>        
            <jsp:directive.include file="header.jsp" />
        </header>

        <article class="principal" id="boleta" style="text-align: center">
            <p >Candidatos</p>

            <%

                try {
                    conectar.Conectar miconexion = new Conectar();
                    String sql = "select * from candidato";
                    ResultSet consulta = miconexion.consulta(sql);

                    while (consulta.next()) {
            %>
            
            <form class="principal" action="realizarvoto.jsp" method="post">

                <%
                    out.println("<img class=principal src=" + consulta.getString(3) + " >");
                %>
                <p style="font-size:20px; font-weight:normal;" >
                    <a>

                        <%=consulta.getString(2)%>
                        <br>

                    </a>

                </p> 
                <p style="font-size:20px; font-weight:normal;" >
                    <a>
                        <input style="width: 10px; background: transparent; border: transparent;" class="label" name=idCandidato type="text" readonly value=<%=consulta.getString(1)%> />
                    </a>
                </p>
                <div class="wrapper" id="voto">
                    <p class="add button">
                        <a>
                            <input id="titulo" type="submit" value="Elegir" />
                        </a>
                    </p>
                </div>
            </form>

            <%
                    }
                } catch (Exception e) {
                    e.getMessage();
                }
            %>





        </article>
        <footer>
            <jsp:directive.include file="footer.jsp" />
        </footer>
    </body>
</html>